package com.neusoft.kc.controller;

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.neusoft.kc.model.Admin;  
import com.neusoft.kc.service.AdminService;  
import com.neusoft.kc.utils.*;


@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    /**
     * 登录
     */
    @ResponseBody
    @RequestMapping(value="/login",method=RequestMethod.POST)
    public Result<?> login(Admin admin){
    	Admin ad=adminService.login(admin);
    	if(ad!=null){
    		return ResultGenerator.genSuccessResult(ad);
    	}else{
    		return ResultGenerator.genFailResult(null);
    	}
    }

    
    /**
     * 更新
     */
    @ResponseBody
    @RequestMapping(value="/update",method=RequestMethod.POST)
    public Result<String> update(@RequestBody Admin admin){
    	int res=adminService.updateByPrimaryKey(admin);
    	if(res==1){
    		return ResultGenerator.genSuccessResult();
    	}else{
    		return ResultGenerator.genFailResult(null);
    	}
    }
}